<!-- <template>
  <div id="app">
    <div class="flex">
      <div>
        <h2 @click="$router.push('/')">首页</h2>
        <h2 @click="$router.push('/about')">关于</h2>
      </div>
      <div>
        <transition name="slide-fade" mode="out-in">
          <router-view></router-view>
        </transition>
      </div>
    </div>
  </div>
</template>

<style>
.flex {
  width: 100vw;
  height: 100vh;
  display: flex;
}

/* 放在全局样式文件中 */
.slide-fade-enter-active {
  transition: all 0.3s ease-out;
}

.slide-fade-leave-active {
  transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
}

.slide-fade-enter-from,
.slide-fade-leave-to {
  transform: translateX(20px);
  opacity: 0;
}
</style> -->






<template>
  <div>
    <skeleton v-if="isLoading" />
    <div v-else>
      <!-- 实际内容 -->
      <div id="app">
        <div class="app-container">
          <nav class="sidebar">
            <div class="logo">Vue Transition</div>
            <ul class="nav-menu">
              <li class="nav-item" :class="{ active: $route.path === '/' }" @click="navigateTo('/')">
                <span class="nav-icon">🏠</span>
                <span class="nav-text">首页</span>
              </li>
              <li class="nav-item" :class="{ active: $route.path === '/about' }" @click="navigateTo('/about')">
                <span class="nav-icon">😍</span>
                <span class="nav-text">关于</span>
              </li>
            </ul>
          </nav>

          <main class="content-area">
            <transition name="slide-fade" mode="out-in">
              <router-view class="page-content" />
            </transition>
          </main>
        </div>
      </div>
      <!-- 实际内容 -->
    </div>
  </div>
</template>

<script>
import Skeleton from './components/Skeleton.vue';

export default {
  components: { Skeleton },
  data() {
    return {
      isLoading: true
    };
  },
  async created() {
    await this.fetchData();
    this.isLoading = false;
  },
  methods: {
    async fetchData() {
      // 模拟数据加载
      return new Promise(resolve => setTimeout(resolve, 2000));
    },
    navigateTo(path) {
      if (this.$route.path !== path) {
        this.$router.push(path)
      }
    }
  }
}
</script>

<style>
/* 基础样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#app {
  height: 100vh;
  background: #f5f7fa;
}

.app-container {
  display: flex;
  height: 100%;
}

/* 侧边栏样式 */
.sidebar {
  width: 240px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px 0;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
  padding: 0 20px 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-menu {
  list-style: none;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.2);
  border-left: 3px solid white;
}

.nav-icon {
  margin-right: 10px;
  font-size: 1.1rem;
}

.nav-text {
  font-size: 0.95rem;
}

/* 内容区域样式 */
.content-area {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
}

.page-content {
  background: white;
  border-radius: 8px;
  padding: 30px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  min-height: calc(100% - 60px);
}

/* 过渡动画效果 */
.slide-fade-enter-active {
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.slide-fade-leave-active {
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.slide-fade-enter-from {
  opacity: 0;
  transform: translateX(30px) scale(0.98);
}

.slide-fade-leave-to {
  opacity: 0;
  transform: translateX(-30px) scale(0.98);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
  }

  .content-area {
    padding: 20px;
  }

  .page-content {
    padding: 20px;
    min-height: auto;
  }
}
</style>